#include <solution.h>

Solution::Item::Item() : coordinate(0, 0), sensor(SENSOR_NO) {}
Solution::Item::Item(Coordinate &c, Sensor s) : coordinate(c), sensor(s) {}

Solution::Solution() : money(0) {

}

const bool Solution::empty() const {
	return solution.empty();
}

void Solution::push(Coordinate &coordinate, Sensor sensor) {
	solution.push_back(Item(coordinate, sensor));
	money += sensorPrice(sensor);
}

void Solution::pop() {
	money -= sensorPrice(solution.back().sensor);
	solution.pop_back();
}

const Solution::Item& Solution::back() const {
	return solution.back();
}

const int Solution::price() const {
	return money;
}

ostream& operator<<(ostream &out, const Solution &s) {
	
	cout << s.solution.size() << " " << s.money << endl;

	for(list< Solution::Item >::const_iterator i = s.solution.begin();
		i != s.solution.end(); i++) {
		out << (int) (i->sensor) << " " << i->coordinate << endl;
	}

	return out;
}